import time

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

from common.Utils import BlogDriver


class BlogDetail:
    url = ''
    driver = ''
    def __init__(self):
        self.url = 'http://127.0.0.1:58080/index.html'
        self.driver = BlogDriver.driver
        self.driver.get(self.url)
        self.driver.implicitly_wait(10)

    # 测试正常发布的博客详情页（登录状态下）
    def DetailTestByLogin(self):

        # 测试博客标题是否存在  并且点击 进入这篇博客详情页
        self.driver.find_element(By.CSS_SELECTOR,"#artical-items-body > div:nth-child(1) > div > div.col > div.text-truncate > a").click()

        # 测试是否能获得title
        title = self.driver.find_element(By.CSS_SELECTOR,"#details_article_content_title").text
        print(title)

        # 测试是否能获得content
        content = self.driver.find_element(By.CSS_SELECTOR, "#details_article_content > p").text
        print(content)

        # 测试点赞按钮是否能点击
        self.driver.find_element(By.CSS_SELECTOR,"#details_btn_like_count").click()
        # 添加屏幕截图
        BlogDriver.getScreeShot()

    # 测试博客详情页（未登录状态下）


# detail = BlogDetail()
# detail.DetailTestByLogin()

